<template>
  <div class="headerWarp flex flex-justify-between ">
    <div class="flex flex-items-center">
      <img src="../../assets/icons/logo.svg" style="width: 90px; height: 32px;" />
      <p class="header">留样柜后台管理系统</p>
    </div>
    <div class="avatarBox flex flex-items-center">
      <el-avatar :src="avaterImg" v-if="avaterImg"> </el-avatar>
      <el-avatar v-else>user</el-avatar>
      <p class="userName">{{ userStore.pinia_userInfo.baseInfo.name }}</p>
      <div class="menuBox ">
        <p class="menuItem" @click="logout">退出登录</p>
        <!-- <p class="menuItem">个人中心</p> -->
      </div>
    </div>

  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";
import { useUserStore } from "@/store/modules/user";
const router = useRouter();
const userStore = useUserStore();
const avaterImg = userStore.pinia_userInfo.baseInfo.headPortrait;

const logout = () => {
  userStore.logout();
  console.log(8888);
};
</script>

<style lang="scss" scoped>
@keyframes fade-in {
  0% {
    opacity: 0;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

.headerWarp {
  width: 100%;
  height: $headerHeight;
  background: #0052d9;
  padding: 0 25px;
  z-index: 1000;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;

  .header {
    font-family: PingFang SC;
    font-size: 14px;
    font-weight: 600;
    line-height: 14px;
    margin-left: 25px;
    color: #ffffff;
  }
}

.avatarBox {
  cursor: pointer;
  position: relative;
  height: 100%;

  &:hover {
    .menuBox {
      display: block;
      width: 100px;
      // height: 60px;
    }
  }

  .userName {
    //styleName: 中文简体R/H10;
    font-size: 12px;
    font-weight: 400;
    line-height: 20px;
    color: #ffffff;
    padding: 0 6px;
  }

  .menuBox {
    display: none;
    position: absolute;
    padding: 12px;
    margin: auto;
    border-radius: 8px;
    top: 60px;
    background: #fff;

    &::before {
      content: "";
      width: 0;
      height: 0;
      border: 12px solid;
      border-color: transparent transparent #ffffff transparent;
      position: absolute;
      top: -20px;
    }

    .menuItem {
      font-size: 16px;
      line-height: 30px;
      text-align: center;
      cursor: pointer;

      &:hover {
        color: #0052d9;
      }
    }
  }
}
</style>